package com.hao;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class PWorkQueues {
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory factory = new ConnectionFactory();

        factory.setHost("8.130.120.148");
        factory.setPort(5672);
//
        factory.setVirtualHost("/kaiyuan");
        factory.setUsername("shihao");
        factory.setPassword("shihao");
        Connection connection = factory.newConnection();

        Channel channel = connection.createChannel();
        channel.queueDeclare("work_queues",true,false,true,null);


        for (int i = 1; i <= 10; i++) {
            String body = i+"hello rabbitmq11~~~";
            channel.basicPublish("","work_queues",null,body.getBytes());
        }


        channel.close();
        connection.close();
    }
}
